<script>
	import request from './apiRequest/request.js'
	export default {
		onLaunch: function() {
			console.log('App Launch')
			//#ifdef APP-PLUS
			plus.screen.lockOrientation('portrait-primary');
			//#endif
			let user = uni.getStorageSync('user')
			if(!user){
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		},
		onShow: function() {
			console.log('App Show')
			//#ifdef APP-PLUS
			request.initApp().then((res=>{
				console.log(res.data)
				let appInfo = res.data
				uni.setStorageSync('appInfo',appInfo)
				plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
					console.log(wgtinfo.versionCode);   //版本号
					if(appInfo.version_code > wgtinfo.versionCode){
						uni.removeStorageSync('user')
						uni.reLaunch({
							url: '/pages/login/login'
						})
						uni.showModal({
							title:'版本更新',
							content: '检测到新版本，请更新到最新!',
							showCancel: false,
							success: function (res) {
								if (res.confirm) {
									plus.runtime.openURL(appInfo.download, function(err){
										console.log(err)
									} );
									console.log('用户点击确定');
								} else if (res.cancel) {
									console.log('用户点击取消');
								}
							}
						})
						
					}
				})
			}))
			//#endif
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	
	@import url("./font_icon/iconfont.css");
	
	.status_bar {
	      height: var(--status-bar-height);
	      width: 100%;
		  z-index: 1000;
	 }
	.flexCol{
		display: flex;
		flex-direction: column;
	}
	.flexRow{
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
	}
	.custom_bar{
		padding: 14rpx 0 ;
		align-items: center;
	}
	.custom_bar_center{
		flex: 1;
	}
	.custom_bar_right{
		justify-content: center;
		align-items: center;
		margin: 0 40rpx;
	}
	.custom_bar_right text{
		font-size:20rpx;
		font-family:Source Han Sans SC;
		font-weight:500;
		line-height: 26rpx;
	}
	.custom_bar_right .icon-kefu{
		font-size: 36rpx;
		line-height: 36rpx;
	}
	.task_label{
		padding: 24rpx 0;
		align-items: center;
	}
	.task_label>image{
		width: 13rpx;
		height: 40rpx;
		margin-right: 14rpx;
	}
	.task_label>view{
		font-size:34rpx;
		line-height: 34rpx;
		font-family:Source Han Sans SC;
		font-weight:500;
		color:rgba(51,51,51,1);
	}
	
	.text-ellipsis{
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}
	.text-ellipsis-2{
		text-overflow: ellipsis;
		overflow: hidden;
		display: -webkit-box!important;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.text-ellipsis-3{
		text-overflow: ellipsis;
		overflow: hidden;
		display: -webkit-box!important;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
	}
	button.button-hover{
		pointer-events: none;
	}
	.notclick {
	    pointer-events: none; 
	}
</style>
